<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <title>添加/修改页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../../component/elementUI/index.css">
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"></el-input>
    <link rel="stylesheet" href="../../../style/wangeditor.css">
    <link rel="stylesheet" href="../../../style/index.css">
</head>

<body>
    <div id="app" v-cloak>
        <div class="add">
            <div class="header">
                <span>{{(action == 'Add'?'添加':'修改')}}基地信息</span>
            </div>
            <div class="main" style="padding: 0 15px;">
                <!-- 配置属性, 目前仅支持 单主表 多子表 结构 -->
                <div id="form" :data-options="JSON.stringify({'tableName':'traceability_base','formName':'dataForm' ,'primaryKey':'Traceability_Base_SerialNumber'})">
                    <div :data-options="JSON.stringify({'tableName':'traceability_base_mapping_qualification','formName':'childDataForm' ,'parentTableName':'traceability_base'})">
                    </div>
                </div>
                
                <div class="table_titel">
                    <div class="titel">基地信息</div>
                </div>

                <el-form :model="dataForm" ref="form" :inline-message="true" style="width: 100%">
                    <el-descriptions :column="1" size="large" border>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">基地名称</div>
                            </template>
                            <el-form-item prop="Traceability_Base_Name"
                                :rules="[{ required: true, message: '请输入基地名称', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Traceability_Base_Name"
                                    placeholder="请输入基地名称"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">地址（省-市-区）</div>
                            </template>
                            <el-form-item prop="CountyNumber"
                                :rules="[{ required: true, message: '请选择地址', trigger: 'change' }]">
                                <el-cascader @change="changeCity" v-model.trim="dataForm.CountyNumber" filterable
                                    :props="{label:'name',value:'code',emitPath:false}" :options="city" clearable
                                    placeholder="请选择地址" style="width: 100%;"></el-cascader>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">详细地址</div>
                            </template>
                            <el-form-item prop="Detailed_Address"
                                :rules="[{ required: true, message: '请输入详细地址', trigger: 'blur' }]">
                                <el-input :disabled="!dataForm.CountyNumber" v-model.trim="dataForm.Detailed_Address"
                                    placeholder="请输入详细地址"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">面积（亩）</div>
                            </template>
                            <el-form-item prop="Traceability_Base_Area"
                                :rules="[{ required: true, message: '请输入面积（亩）', trigger: 'blur' }]">
                                <el-input v-model.trim="dataForm.Traceability_Base_Area"
                                    placeholder="请输入面积（亩）"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                    </el-descriptions>
                </el-form>

                <div class="table_titel">
                    <div class="titel">资质认证</div>
                    <div class="operation">
                        <el-button type="primary" size="small" @click="handleAdd('childDataForm')">新增</el-button>
                        <el-button type="danger" size="small" @click="handleRemove('childDataForm')">删除</el-button>
                    </div>
                </div>
                <el-form :model="{childDataForm:childDataForm.filter(i=>i.Row_Status != '1')}" ref="childForm"
                    :inline-message="true" style="width: 100%">
                    <el-descriptions :column="3" size="large" border
                        v-for="(item,index) in childDataForm.filter(i=>i.Row_Status != '1')" :key="index">
                        <el-descriptions-item>

                            <template slot="label">
                                <div class="cell-item">资质类别</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Qualification_Category_SerialNumber`"
                                :rules="[{ required: true, message: '请选择资质类别', trigger: 'change' }]">
                                <el-select v-model.trim="item.Qualification_Category_SerialNumber" placeholder="请选择资质类别"
                                    style="width: 100%;" clearable filterable>
                                    <el-option v-for="(item,index) in qualification_category" :key="index"
                                        :label="item.Qualification_Category"
                                        :value="item.Qualification_Category_SerialNumber" />
                                </el-select>
                            </el-form-item>

                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">资质编码</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Qualification_Number`"
                                :rules="[{ required: true, message: '请输入资质编码', trigger: 'blur' }]">
                                <el-input v-model.trim="item.Qualification_Number" placeholder="请输入资质编码"></el-input>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">过期日期</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Expired_Datetime`">
                                <el-date-picker @change="handleDate($event,item)" v-model.trim="item.Expired_Datetime"
                                    format="yyyy-MM-dd" style="width: 100%;" value-format="yyyy-MM-dd" type="date"
                                    placeholder="可选择过期日期" size="large"></el-date-picker>
                            </el-form-item>
                        </el-descriptions-item>
                        <el-descriptions-item>
                            <template slot="label">
                                <div class="cell-item">资质图片</div>
                            </template>
                            <el-form-item :prop="`childDataForm.${index}.Picture_URL`"
                                :rules="[{ required: true, message: '请上传资质图片', trigger: 'change' }]">
                                <yl-upload v-model="item.Picture_URL"></yl-upload>
                            </el-form-item>
                        </el-descriptions-item>
                    </el-descriptions>
                </el-form>
            </div>
            <div class="footer">
                <el-button size="medium" @click="handleBack">返回</el-button>
                <el-button size="medium" type="primary" plain @click="handleSubmit" :loading="loading">提交</el-button>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../../../utils/wangeditor.js"></script>
    <script type="text/javascript" src="../../../utils/xlsx.full.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.min.js"></script>
    <script type="text/javascript" src="../../../utils/jquery.cookie.js"></script>
    <script type="text/javascript" src="../../../utils/vue.min.js"></script>
    <script type="text/javascript" src="../../../utils/vuex.min.js"></script>
    <script type="text/javascript" src="../../../component/elementUI/index.js"></script>
    <script type="text/javascript" src="../../../utils/components.js"></script>
    <script type="text/javascript" src="../../../utils/compressor.js"></script>
    <script type="text/javascript" src="../../../utils/validity.js"></script>
    <script type="text/javascript" src="../../../utils/utils.js"></script>
    <script type="text/javascript" src="../../../utils/http.js"></script>
    <script type="text/javascript" src="js/add.js"></script>
</body>

</html>